//
//  MainTabBarController.m
//  TenThousand
//
//  Created by baixue on 16/6/6.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "MainTabBarController.h"
#import "UIImage+Color.h"
#import "UIImage+Scale.h"
#import "HomeViewController.h"
#import "InvestmentViewController.h"
#import "WealthViewController.h"
#import "DiscoverViewController.h"
#import "OtherViewController.h"
#define vcStringArray @[@"HomeViewController",@"InvestmentViewController",@"DiscoverViewController",@"WealthViewController",@"OtherViewController"]
#define vcTitleArray @[@"推荐",@"投资",@"发现",@"财富",@"更多"]
#define vcImageArray @[@"1",@"2",@"3",@"4.jpg'",@"5"]


@interface MainTabBarController ()


@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSArray *tem = @[@"1-2",@"2-1",@"3-1",@"4-1.jpg'",@"5-1"];
    [self.tabBar setTintColor:[UIColor colorWithRed:0.55 green:0.00 blue:0.00 alpha:1.00]];

    HomeViewController *home = [[HomeViewController alloc] init];
    InvestmentViewController *home1 = [[InvestmentViewController alloc] init];
    DiscoverViewController *home2 = [[DiscoverViewController alloc] init];
    WealthViewController *home3 = [[WealthViewController alloc] init];
    OtherViewController *home4 = [[OtherViewController alloc] init];
    NSArray *arr = @[home,home1,home2,home3,home4];
    for (NSInteger i = 0; i < arr.count; i ++) {
        
          [self addChildViewControllers:arr[i] andImage:[UIImage imageNamed:tem[i]] andSelectedImage:[UIImage imageNamed:vcImageArray[i]] andTitle:vcTitleArray[i]];
        
    }
    
}
- (void)addChildViewControllers:(UIViewController *)viewController andImage:(UIImage *)image andSelectedImage:(UIImage *)selectedImage andTitle:(NSString *)controllerName {
    
    UINavigationController *baseController = [[UINavigationController alloc] initWithRootViewController:viewController];
    
    viewController.tabBarItem.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [baseController.navigationBar setTintColor:[UIColor whiteColor]];
    baseController.navigationBar.backgroundColor = [UIColor whiteColor];
    [baseController.navigationBar setBackgroundImage:[UIImage imageNamed:@"CF1_01"] forBarMetrics:UIBarMetricsDefault];
    baseController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
    viewController.tabBarItem.selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    viewController.title = controllerName;
    
    //    [self.tabBarController addChildViewController:baseController];
    
    [self addChildViewController:baseController];
    
}
//隐藏多余的分割线
+ (void)setExtraCellLineHidden: (UITableView *)tableView
{
    UIView *view = [UIView new];
//    view.backgroundColor = [UIColor clearColor];
    [tableView setTableFooterView:view];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




@end
